package com.cz.nongyetongv5.utils;

import android.content.res.Resources;

import com.cz.nongyetongv5.R;

public class ConfigUtil {

	private Resources resources = null;

	public ConfigUtil(Resources resources) {
		this.resources = resources;
	}

	/**
	 * 1是js ,2是cz
	 *
	 * @return
	 */
	public int getConfig() {

		return Integer.parseInt(resources.getString(R.string.config));

	}

	public String getRegionCode() {

		String quyuma = resources.getString(com.cz.nongyetongv5.R.string.quyuma);

		return quyuma;

	}

	public boolean containerRegionCode(String regionCode) {

		if (regionCode.startsWith(getRegionCode())) {

			return true;
		} else {
			return false;
		}

	}

	public boolean gis() {

		return parseBoolean(resources.getString(R.string.gis));

	}

	public boolean jiandujiancha() {

		return parseBoolean(resources.getString(R.string.jiandujiancha));
	}

	public boolean duchaxuncha() {

		return parseBoolean(resources.getString(R.string.duchaxuncha));
	}

	public boolean sanpinchaxun() {
		return parseBoolean(resources.getString(R.string.sanpinchaxun));
	}

	public boolean tourupinchaxun() {
		return parseBoolean(resources.getString(R.string.tourupinchaxun));
	}

	public boolean hudongjiaoliu() {
		return parseBoolean(resources.getString(R.string.hudongjiaoliu));
	}



	public boolean daiban() {

		return parseBoolean(resources.getString(R.string.daiban));
	}

	private boolean parseBoolean(String bool) {
		return Boolean.parseBoolean(bool);
	}

	public String getRestUsername() {

		if (getConfig() == 1) {

			return resources.getString(R.string.rest_username_js);
		} else if (getConfig() == 2) {
			return resources.getString(R.string.rest_username_cz);

		} else {
			return null;
		}
	}

	public String getRestPassword() {
		if (getConfig() == 1) {
			return resources.getString(R.string.rest_password_js);
		} else if (getConfig() == 2) {
			return resources.getString(R.string.rest_password_cz);

		} else {
			return null;
		}
	}

	public String getPreHttpUrl() {

		if (getConfig() == 1) {
			return resources.getString(R.string.http_pre_js);
		} else if (getConfig() == 2) {
			return resources.getString(R.string.http_pre_cz);
		} else {
			return null;
		}

	}

	public String getChouYangUrl() {

		return getPreHttpUrl()
				+ resources.getString(R.string.upload_chanpinjiance);

	}

	public String getPlanChouYangUrl() {

		return  resources.getString(R.string.upload_planchanpinjiance);

	}


}
